import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import Invitation from './views/Invitation';
import AppDownload from './views/AppDownload';
import SignPay from './views/SignPay';
import MyScore from './views/MyScore';
import SignHome from './views/SignHome';
import RuleDetail from './views/RuleDetail'

Vue.use(Router);

const router =  new Router({
    routes: [
        {
            path: '/',
            name: 'home',
            component: Home
        },
        {
            path: '/invitation',
            name: 'Invitation',
            component: Invitation,
            meta: {
                auth: false
            }
        },
        {
            path: '/download',
            name: 'Download',
            component: AppDownload,
            meta: {
                auth: false
            }
        },
        {
            path: '/sign-pay',
            name: 'SignPay',
            component: SignPay,
            meta: {
                auth: true
            }
        },
        {
            path: '/my-score/:share?',
            name: 'MyScore',
            component: MyScore,
            meta: {
                auth: true
            }
        },
        {
            path: '/home',
            name: 'SignHome',
            component: SignHome,
            meta: {
                auth: true
            }

        },
        {
            path: '/rule-detail',
            name: 'RuleDetail',
            component: RuleDetail,
            meta: {
                auth: true
            }
        }
    ]
});

router.afterEach(()=> {
    setTimeout(() => {
        if(document.documentElement) {
            document.documentElement.scrollTop = 0;
        } else {
            document.body.scrollTop = 0;
        }
    }, 100);
});

export default router;
